/**
 *
 */
package org.misalen.web.admin.shiro;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

/**
 * 自定义Authentication对象，使得Subject除了携带用户的登录名外还可以携带更多信息
 * 
 * @author guochao
 *
 */
public class ShiroUser implements Serializable {

	private static final long serialVersionUID = -1373760761780840081L;
	private String userId;
	private String nickname;
	private String username;
	private Set<String> roleSet = new HashSet<String>();

	public ShiroUser(String userId, String nickname, String username) {
		super();
		this.userId = userId;
		this.nickname = nickname;
		this.username = username;
	}

	public Set<String> getRoleSet() {
		return roleSet;
	}

	public void setRoleSet(Set<String> roleSet) {
		this.roleSet = roleSet;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getNickname() {
		return nickname;
	}

	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getBelongCity() {
		if(roleSet.contains("admin") || roleSet.contains("agent-national")) {
			return "全国";
		}
		if(roleSet.contains("agent-lanzhou")) {
			return "兰州";
		}
		if(roleSet.contains("agent-shanghai")) {
			return "上海";
		}
		return "全国";
	}
	/**
	 * 本函数输出将作为默认的<shiro:principal/>输出.
	 */
	@Override
	public String toString() {
		return nickname;
	}
}